//
//  MZGlobleConfig.m
//  MZSystem
//
//  Created by Beyondream on 2018/11/9.
//  Copyright © 2018 zerod. All rights reserved.
//

#import "MZGlobleConfig.h"

@implementation MZGlobleConfig

+ (instancetype)defaultManager {
    static MZGlobleConfig * config = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        config = [[MZGlobleConfig alloc]init];
    });
    return config;
}

//视频 码率（BitRate）、
- (void)setVideoBitRate:(NSUInteger)videoBitRate {
    [[NSUserDefaults standardUserDefaults] setObject:@(videoBitRate) forKey:@"videoBitRate"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

- (NSUInteger)videoBitRate {
    if (![[NSUserDefaults standardUserDefaults]objectForKey:@"videoBitRate"]) {
        return 1500;
    }
    return [[[NSUserDefaults standardUserDefaults]objectForKey:@"videoBitRate"] integerValue];
}

//FPS 帧率（frame per second）
- (void)setVideoFrameRate:(NSUInteger)videoFrameRate {
    [[NSUserDefaults standardUserDefaults] setObject:@(videoFrameRate) forKey:@"videoFrameRate"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

- (NSUInteger)videoFrameRate {
    if (![[NSUserDefaults standardUserDefaults]objectForKey:@"videoFrameRate"]) {
        return 15;
    }
   return [[[NSUserDefaults standardUserDefaults]objectForKey:@"videoFrameRate"] integerValue];
}


//分辨率（VideoSize）
- (void)setVideoSize:(CGSize)videoSize {
    [[NSUserDefaults standardUserDefaults] setObject:NSStringFromCGSize(videoSize) forKey:@"videoSize"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

- (CGSize)videoSize {
    if (![[NSUserDefaults standardUserDefaults]objectForKey:@"videoSize"]) {
        return CGSizeMake(1280, 720);
    }
    return CGSizeFromString([[NSUserDefaults standardUserDefaults]objectForKey:@"videoSize"]);
}
@end
